const express = require("express");
const app = express();
const session = require("express-session");
app.use(session({
    secret: 'secret', // 对session id 相关的cookie 进行签名
    resave: true,
    saveUninitialized: false, // 是否保存未初始化的会话
    cookie: {
        maxAge: 1000 * 60 * 3, // 设置 session 的有效时间，单位毫秒
    },
}))

app.get("/b", (req, res) => {
    // console.log(req.session)
    if (!req.session["xxx"]) {
        req.session['xxx'] = 1;
    } else {
        req.session['xxx']++;
    }
    req.session['amount'] = 99.8;
    res.send(`欢迎你第${req.session["xxx"]}次登陆,你的余额是:${req.session['amount']}`)
})




app.listen(3000)